import sys

from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtGui import QDoubleValidator
from PyQt6.QtWidgets import QApplication

from circle_ca import Ui_Dialog

if __name__ == '__main__':
    class circle_cal_main(Ui_Dialog,QtWidgets.QDialog):
        def __init__(self):
            super(circle_cal_main,self).__init__()
            self.setupUi(self)
            double_validator = QDoubleValidator(0, 100.0, 2)
            self.lineEdit.setValidator(double_validator)
        def cal_cirle(self):
            str_ = self.lineEdit.text()

            if (len(str_) > 0):
                radio = float(str_)
                leng = 2 * 3.14159 * radio
                area = 3.14159 * radio * radio
                self.lineEdit_2.setText(str(leng))
                self.lineEdit_3.setText(str(area))
            else:
                self.lineEdit_2.setText('0')
                self.lineEdit_3.setText('0')

    app = QApplication(sys.argv)
    dlg = circle_cal_main()
    dlg.show()
    sys.exit(app.exec())